<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="title">
        HelpDeskRu:ServiceZone
    </ui:define>

    <ui:define name="top_menu">
        <ui:include src="/service/main_menu.xhtml"/>
    </ui:define>


    <ui:define name="content">

        <h:form id="form">
            
            <p:selectBooleanButton value="#{serviceClosedRequests.showRequestOnlyForCurrentUser}" 
                                   valueChangeListener="#{serviceClosedRequests.showRequestChangeListener}"
                                   onLabel="#{prop['service.showRequestOnlyForCurrentUser.onLabel']}" 
                                   offLabel="#{prop['service.showRequestOnlyForCurrentUser.offLabel']}">

                <p:ajax update="@form"/>
            </p:selectBooleanButton>
            <br/>
            <br/>
             
            <p:dataTable value="#{serviceClosedRequests.listRequest}" var="item" 
                         emptyMessage="" rowKey="#{item.id}" 
                         paginatorAlwaysVisible="false" paginator="true" rows="20"
                         rowsPerPageTemplate="20,50,100">
                
                <f:facet name="header">
                    <h:outputText value="#{prop['service.closed_requests.header']}"/>
                </f:facet>


                <p:column headerText="Id">
                    <p:commandLink value="#{item.id}"
                                         oncomplete="requestDialog.show()"
                                         update=":requestForm:requestPanel">
                        <f:setPropertyActionListener target="#{currentRequestBean.current}" 
                                                     value="#{item}" />
                    </p:commandLink>
                </p:column>

                <p:column headerText="#{prop['common.createdBy']}">
                    <h:outputText value="#{item.createdBy.name}" />
                </p:column>

                <p:column headerText="#{prop['common.createdDate']}">
                    <h:outputText value="#{item.createdDate}">
                        <f:convertDateTime pattern="HH:mm dd.MM.yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="#{prop['common.description']}">
                    <h:outputText value="#{item.description}" />
                </p:column>

                <p:column headerText="#{prop['common.serviceObject']}">
                    <h:outputText value="#{item.serviceObject.name}" />
                </p:column>

                <p:column headerText="#{prop['common.priority']}">
                    <h:outputText value="#{item.priority.name}" />
                </p:column>

                <p:column headerText="#{prop['common.stateRequest']}">
                    <h:outputText value="#{item.stateRequest.name}" />
                </p:column>

                <p:column headerText="#{prop['common.stateDate']}">
                    <h:outputText value="#{item.stateDate}">
                        <f:convertDateTime pattern="HH:mm dd.MM.yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="#{prop['common.performer']}">
                    <h:outputText value="#{item.performer.name}" />
                </p:column>

            </p:dataTable>
            
        </h:form>

    </ui:define>
    
    <ui:define name="dialog_request">
        <ui:include src="/dialogRequest.xhtml"/>
    </ui:define>
    
</ui:composition>

